package com.bys.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class Result {
    private Integer code;
    private String message;
    private Object data;
    public static Result fail(){
        return new Result(ReultCode.FAIL_CODE.getCode(),ReultCode.FAIL_CODE.getMessage());
    }
    public static Result fail(String message){
        return new Result(ReultCode.FAIL_CODE.getCode(),message);
    }
    public static Result fail(Integer code,String message){
        return new Result(code,message);
    }
    public static Result fail(ReultCode code){
        return new Result(code.getCode(),code.getMessage());
    }

    public static Result success(Object data){
        return new Result(ReultCode.SUCCESS_CODE.getCode(),ReultCode.SUCCESS_CODE.getMessage(),data);
    }
    public static Result success(){
        return new Result(ReultCode.SUCCESS_CODE.getCode(),ReultCode.SUCCESS_CODE.getMessage());
    }

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
}
